
export const MessagePopup={
    success:(msg:string,duration?:number)=>{
        uni.showToast({
            icon: 'success',
            title: msg,
            duration:duration || 500
        });
    },
    error:(msg:string,duration?:number)=>{
        uni.showToast({
            icon: 'error',
            title: msg,
            duration:duration || 500
        });
    },
    msg:(msg:string,duration?:number)=>{
        uni.showToast({
            icon: 'none',
            title: msg,
            duration:duration || 500
        });
    },
    // loading:(msg:string,duration?:number)=>{
    //     uni.showToast({
    //         icon: 'loading',
    //         title: msg,
    //         duration:duration || 1000
    //     });
    // },

    showModal:(content:string,confirmCallback:Function,cancelCallback:Function,title?:string)=>{
        uni.showModal({
            title: title || '提示',
            content: content,
            success: function (res) {
                if (res.confirm) {
                    confirmCallback();
                } else if (res.cancel) {
                    cancelCallback();
                }
            }
        });
    },
    /**显示只有确定的弹窗 */
    showOnlyConfirmModal:(content:string,callback:Function,title?:string)=>{
        uni.showModal({
            title: title || '提示',
            content: content,
            showCancel:false,
            success: function (res) {
                if (res.confirm) {
                    callback();
                } 
            }
        });
    }

}